package com.mz.mattress.admin.api.admin;

import com.mz.mattress.admin.service.ActivityItemService;
import com.mz.mattress.api.common.Constants;
import com.mz.mattress.api.common.Result;
import com.mz.mattress.api.entity.ActivityItem;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Set;

@Slf4j
@RestController
@RequestMapping(Constants.ADMIN_PATH + "activityItem")
public class ActivityItemController {

    @Autowired
    private ActivityItemService activityItemService;

    @GetMapping("/list/{id}")
    public Result<List<ActivityItem>> list(@PathVariable Integer id) {
        return activityItemService.selectByActivityId(id);
    }

    @PostMapping
    public Result add(@RequestBody ActivityItem activityItem) {
        return activityItemService.add(activityItem);
    }

    @PutMapping
    public Result update(@RequestBody ActivityItem activityItem) {
        return activityItemService.updateById(activityItem);
    }

    @DeleteMapping
    public Result delete(@RequestBody Set<Integer> ids) {
        return activityItemService.deleteByIds(ids);
    }

}
